/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package uit.qlks.controller.hoadon;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.sql.rowset.WebRowSet;
import uit.ejb.bo.hoadon.HoaDonBORemote;
import uit.ejb.bo.hoadon.HoaDonBORemoteHome;
import uit.ejb.dto.HoaDonDTO;

/**
 *
 * @author Restart
 */
public class HoaDonController {

    private static Context ctx;
    private static HoaDonBORemoteHome phome;
    private static HoaDonBORemote hd;
    public HoaDonController(){

    }

    public static void Register(){
        try{
            ctx = new InitialContext();
            Object obj = ctx.lookup("ejb/HoaDonBO");
            phome = (HoaDonBORemoteHome) PortableRemoteObject.narrow(obj, HoaDonBORemoteHome.class);
            hd=phome.create();
        }
        catch(Exception e){
        }
    }

    public static boolean hoaDon_Insert(HoaDonDTO hoadon) {
        try{
            Register();
            return hd.hoaDon_Insert(hoadon);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean hoaDon_Update(HoaDonDTO hoadon) {
        try{
            Register();
            return hd.hoaDon_Update(hoadon);
        }catch(Exception e){
            return false;
        }
    }

    public static boolean hoaDon_Delete(String id) {
        try{
            Register();
            return hd.hoaDon_Delete(id);
        }catch(Exception e){
            return false;
        }
    }

    public static WebRowSet hoaDon_GetByAll() {
        try{
            Register();
            return hd.hoaDon_GetByAll();
        }catch(Exception e){
            return null;
        }
    }

    public static WebRowSet hoaDon_GetByTop(String top, String where, String order) {
        try{
            Register();
            return hd.hoaDon_GetByTop(top, where, order);
        }catch(Exception e){
            return null;
        }
    }
}
